<script type="text/javascript" src="/static/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/ueditor/ueditor.all.js"></script>


<div class="contact-info">
    <div class="contact-info-grids" style="min-height:550px;">
        <div class="col-md-3 col-sm-3"></div>
        <form action="{:url('ext/index/save')}" method="post" class="col-md-6 col-sm-6" style="margin:0 auto;">
            <div class="input-group input-group-lg ">
                <span class="input-group-addon" id="sizing-addon1">Title:</span>
                <input type="text" name="title" class="form-control" placeholder="" aria-describedby="sizing-addon1">
            </div>
            <div id="editor" style="width:100%;min-height:300px;margin:0 auto;">
            </div>
            <div class="input-group input-group-lg ">
            </div>
            <div class="input-group input-group-lg">
                <button type="button" class="submit-btn label label-primary">提交</button>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    var ue = UE.getEditor('editor');
    var post_url = '{:url("ext/index/save")}';

    $(function(){
        $('.submit-btn').click(function(){
            var content = UE.getEditor('editor').getContent();
            var title = $('input[name="title"]').val();

            $.post(post_url,{
                'title':title,'content':content
            },function(status){
                if(status.code == 1)
                {
                    window.location.href = '{:url("ext/index/detail")}' + '?id=' + status.msg;
                }else{
                    alert('添加失败')
                }
            });
        })
    })
</script>